package com.cloud.form.api.web;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.cloud.form.api.service.FormInterfaceService;
import com.cloud.form.common.result.QkTreeNode;
import com.cloud.form.common.utils.TreeHelper;

@RestController
@RequestMapping("/form/api/interface")
public class FormInterfaceController {

	@Autowired
	private FormInterfaceService formInterfaceService;
	
	@RequestMapping("listformtree")
	public QkTreeNode[] listformtree(long recId, long actDefId, String parts){
		return TreeHelper.buildList2Tree(formInterfaceService.listFormTree(recId, actDefId, parts));
	}
	
	@RequestMapping("listprintformtree")
	public QkTreeNode[] listprintformtree(long recId, long actDefId, String parts){
		return TreeHelper.buildList2Tree(formInterfaceService.listPrintFormTree(recId, actDefId, parts));
	}
	
	/**
	 * 为自定义业务创建表单
	 * @param recId
	 * @param actDefId
	 * @param parts
	 * @return
	 */
	@RequestMapping("createcustomform")
	public Long createCustomForm(Integer bizId, String bizName, Long procDefId){
		return formInterfaceService.createCustomForm(bizId, bizName, procDefId);
	}
}
